<?php


namespace app\common\model;


use think\Model;

class UserLevel extends Model
{
    protected $pk = "level_id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type=[
        'jq_jl_bili'   =>  'float',
        'jl_bili'   =>  'float',
        'cbj_sf_bl'   =>  'float',
        'pj_jl'   =>  'float',
    ];
    public function getPkAttr() {
        return $this->pk;
    }
    //获取升级条件
    public function getTiaoJianTextAttr($value,$data) {
        if ($data['market_num']>0 && $data['num']>0 && $data['num_level_id']>0){
            $level_name=$this->where('level_id',$data['num_level_id'])->value('name');
            return "{$data['market_num']}个市场,每个市场{$data['num']}名{$level_name}";
        }
        return '---';
    }
    //获取团队分红条件
    public function getFhTiaoJianTextAttr($value,$data) {
        if ($data['fh_market_num']>0 && $data['fh_num']>0 && $data['fh_num_level_id']>0){
            $level_name=$this->where('level_id',$data['fh_num_level_id'])->value('name');
            return "{$data['fh_market_num']}个市场,每个市场{$data['fh_num']}名{$level_name}";
        }
        return '---';
    }
    public function getCanUpdateTextAttr($value,$data) {
        $types = [0=>'否',1=>'是'];
        return $types[$data['can_update']];
    }
}
